package dao;


import hbt.HibernateDAO;

import org.hibernate.Session;
import org.hibernate.Transaction;


import bean.ProveedorBean;

public class ProveedorDao {

	public void altaProveedor(ProveedorBean P)
	{
		Session s = HibernateDAO.getInstancia().getSession();
		Transaction t = s.beginTransaction();
		s.persist(P);
		t.commit();
	}
	
	public static ProveedorBean getProveedorByName(String name)
	{
		Session s = HibernateDAO.getInstancia().getSession();
		Transaction t = s.beginTransaction();
		ProveedorBean p=(ProveedorBean)s.createQuery("FROM ProveedorBean WHERE nombre=:nombre").setParameter("nombre", name).uniqueResult();
		
		t.commit();
		
		return p;
		
		
	}
}
